﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using Contracts;

namespace Client
{
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.CodeDom.Compiler.GeneratedCode("System.ServiceModel", "4.0.0.0")]
    public partial class CalculatorServiceClient : System.ServiceModel.ClientBase<Client.CalculatorServiceClient>, Client.ServiceReference1.CalculatorService
    {
        public CalculatorServiceClient() { }
        public CalculatorServiceClient(string endpointConfiguationName)
            : base(endpointConfiguationName) { }
        public CalculatorServiceClient(string endpointConfiguationName, string remoteAddress)
            : base(endpointConfiguationName, remoteAddress) { }
        public CalculatorServiceClient(string endpointConfiguationName, System.ServiceModel.EndpointAddress remoteAddress)
            : base(endpointConfiguationName, remoteAddress) { }
        public CalculatorServiceClient(System.ServiceModel.Channels.Binding bindding,System.ServiceModel.EndpointAddress remoteAddress) { }

        #region CalculatorService 成员

        public double Add(double x, double y)
        {
            return base.Channel.Add(x,y);
        }

        public double Subtract(double x, double y)
        {
            return base.Channel.Subtract(x,y);
        }

        public double Multiply(double x, double y)
        {
            return base.Channel.Multiply(x,y);
        }

        public double Divide(double x, double y)
        {
            return base.Channel.Divide(x,y);
        }

        #endregion
    }


    class Program
    {
        static void Main(string[] args)
        {
            using (ChannelFactory<ICalculator> cf = new ChannelFactory<ICalculator>(new WSHttpBinding(), "http://127.0.0.1:9999/calculatorservice"))
            {
                ICalculator proxy = cf.CreateChannel();
                using (proxy as IDisposable)
                {
                    Console.WriteLine("1+2={0}",proxy.Add(1,2));    
                }
                
            }
            Console.Read();
        }
    }
}
